import React, { useEffect, useState } from "react";
import { Toast } from "antd-mobile";
import { InterfaceG } from "@config/Config";
import yhTools from "@/tools/yh";
import MainLayout from "@/component/mainLayout/mainLayout";
import Banner from "@/views/viewCommon/Banner";

/**银行福利banner落地页 */
const bankWelfareLand = ({ history }) => {
	const [bannerList, setBannerList] = useState([]);

	//获取banner列表
	const getBannerList = () => {
		let objs = {
			url: InterfaceG.getBannerListByPageType,
			params: {
				pageType: "bankWelfarePage"
			},
			_alertShow: false
		};
		yhTools.request(objs).then(res => {
			if (res.code === "0") {
				if (res.data && res.data.length > 0) {
					setBannerList(res.data);
				}
			} else {
				Toast.info(res.message, 2);
			}
		});
	};

	useEffect(() => {
		getBannerList();
	}, []);

	const _pageParams = {
		header: {
			title: "银行福利"
		},
		history
	};

	return (
		<MainLayout pageParams={_pageParams}>
			{bannerList.map((item, index) => {
				return (
					<Banner
						key={index}
						bannerList={item.indexServerDtos}
						history={history}
					/>
				);
			})}
		</MainLayout>
	);
};

export default bankWelfareLand;
